/*
 * @Description: 顶部导航栏js
 * @Author: zhangchenna
 * @Date: 2019-02-25 17:06:37
 * @LastEditTime: 2019-04-23 16:58:22
 */
import '../style/common/common.scss';
import Swiper from 'swiper';
import 'swiper/dist/css/swiper.css';

let headerSwiper = new Swiper('.header-swiper', {
    speed: 3000,
    autoplay: {
        delay: 3000
    }
});

headerSwiper;

let navList = document.querySelectorAll('.header-nav-item'),
    navChildList = document.querySelectorAll('.header-nav-item-child');

for (let i = 0; i < navList.length; i++) {
    navList[i].addEventListener(
        'mouseenter',
        function() {
            navChildList.forEach(item => {
                if (!item.className.includes('mit-hide')) {
                    item.classList.add('mit-hide');
                }
            });
            this.children[1].classList.remove('mit-hide');
        },
        false
    );
}

for (let i = 0; i < navChildList.length; i++) {
    navChildList[i].addEventListener(
        'mouseleave',
        function() {
            this.classList.add('mit-hide');
        },
        false
    );
}
